/*---------------------------------------------------------------------------------*/
//ORGANIZATION:
//AUTHOR: bpeng(bogers.peng@gmail.com)
//SUMMARY:
/*---------------------------------------------------------------------------------*/
#include "../Bool.h"
#include "../Atom.h"

using namespace Native::System;

CBool::CBool() :
    _value(false)
{
}

CBool::CBool(const CBool& that) :
    _value(that._value)
{
}

CBool::CBool(const CBool&& that):
    _value(that._value)
{
}

CBool::CBool(bool value) :
    _value(value)
{
}

CBool::CBool(WSTRING& value) throw()
{
    wstring lower_value = UString::ToLower(value);

    if(lower_value == L"true") {
        _value = true;
    } else if(lower_value == L"false") {
        _value = false;
    } else {
        //TODO: Throw exception
    }
}

wstring CBool::ToString() const
{
    return _value? L"True" : L"False";
}

bool CBool::operator==(const CBool& rvalue) const
{
    return _value == rvalue._value;
}

bool CBool::operator!=(const CBool& rvalue) const
{
    return !operator==(rvalue);
}

const CBool& CBool::operator=(const CBool& rvalue)
{
    CObject::operator=(rvalue);

    _value = rvalue._value;

    return *this;
}

const CBool& CBool::operator=(bool rvalue)
{
    _value = rvalue;

    return *this;
}
